package work.content.fileSizeValid;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class Main1 {
    private static final String dir = "C:\\Users\\Gong.Yang\\Desktop\\content\\2023-12-12\\scrm";
    private static final String out = "C:\\java-demo\\javademo\\demo-work\\src\\main\\java\\work\\content\\fileSizeValid\\out.csv";

    public static void main(String[] args) {
        List<File> files = FileUtil.loopFiles(dir);
        List<String> result = new ArrayList<>();
        for (File file : files) {
            if (file.isDirectory()) continue;
            long sizeMb = file.length() / 1024 / 1024;
            if (sizeMb >= 200) {
                String path = file.getAbsolutePath().substring(dir.length());
                result.add(path.concat(",") + sizeMb);
            }
        }

        String join = String.join("\n", result);
        FileUtil.writeString(join, out, Charset.defaultCharset());
    }
}
